package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入查找的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int count = bookList.getUseSize();
        int i = 0;
        for ( i = 0; i < count; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                System.out.println(book);
                System.out.println("查找成功");
                return;
            }
        }
        if (i == count){
            System.out.println("未查找到"+name+"这本书");
        }

    }
}
